package com.yjh.study.data.structure;

import java.util.Objects;

public interface Collection<T> extends Iterable<T> {

    int size();

    boolean isEmpty();

    void add(T t);

    void remove(T t);

    void clear();

    default void addAll(Collection<T> collection) {
        for (T t : collection) {
            this.add(t);
        }
    }

    default boolean contain(T t) {
        for (T next : this) {
            if (Objects.equals(t, next)) {
                return true;
            }
        }
        return false;
    }
}
